#!/usr/bin/env python
# -*- coding: latin-1 -*-
from Tkinter import *
import tkMessageBox

class Menu():
	def __init__(self):
		self.output = ""
		self.value = False
		self.root = None
		self.on = False

	def popup(self, titulo, etiqueta):
		if self.on: 
			return None
		self.root = Tk(); self.root.title(str(titulo))
		self.root["padx"] = 40; self.root["pady"] = 20       

		textFrame = Frame(self.root)

		entryLabel = Label(textFrame); entryLabel["text"] = str(etiqueta)
		entryLabel.pack(side=LEFT)

		textFrame.pack()

		def destroyEntry():
			self.root.destroy()
			self.on = False
			self.root = None

		button = Button(self.root, text="Aceptar", command=destroyEntry)
		button.pack() 
		self.on = True
		self.root.mainloop()
		return None


	def fieldup(self, titulo, etiqueta):
		self.root = Tk(); self.root.title(str(titulo))
		self.root["padx"] = 40; self.root["pady"] = 20       

		textFrame = Frame(self.root)

		entryLabel = Label(textFrame); entryLabel["text"] = str(etiqueta)
		entryLabel.pack(side=LEFT)

		entryWidget = Entry(textFrame); entryWidget["width"] = 20
		entryWidget.pack(side=LEFT)

		textFrame.pack()

		self.output = ""
		def destroyEntry():
			self.output = entryWidget.get().strip()
			self.root.destroy()
			self.root = None

		button = Button(self.root, text="Aceptar", command=destroyEntry)
		button.pack() 
		self.root.mainloop()
		print self.output
		return self.output
			
	def select(self):
		self.root = Tk(); self.root.title("Comienzo")
		self.root["padx"] = 40; self.root["pady"] = 20       

		textFrame = Frame(self.root)

		entryLabel = Label(textFrame); entryLabel["text"] = "Ud. sera el servidor?"
		entryLabel.pack(side=LEFT)

		textFrame.pack()

		def destroyEntryTrue():
			self.value = True
			self.root.destroy()
			self.root = None

		def destroyEntryFalse():
			self.value = False
			self.root.destroy()
			self.root = None

		button = Button(self.root, text="Si", command=destroyEntryTrue)
		button.pack()
		button = Button(self.root, text="No, sere Cliente", command=destroyEntryFalse)
		button.pack()  
		self.root.mainloop()
		return self.value

